package Views;

import Source.CreateAirport;
import UCM.UCCreateAirport;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author Joshua King
 */
public class ViewCreateAirport extends JPanel {
    private static String TEXT = "Error!111ewrc";
    private static String TEXT2 = "Success!LKJAS";
    private static int MAXCHAR = 10;
    private JLabel airportNameLabel = new JLabel("Airport Name");
    private JLabel airportLocationLabel = new JLabel("Airport Location");
    private JLabel airportTaxLabel = new JLabel("Airport Tax");
    private JTextField airportNameTxt = new JTextField(MAXCHAR);
    private JTextField airportLocationTxt = new JTextField(MAXCHAR);
    private JTextField airportTaxTxt = new JTextField(MAXCHAR);
    private JButton airportButton = new JButton("Construct Airport");
    private UCCreateAirport UCCreateAirport = new UCCreateAirport(this);
    private CreateAirport model;
    private JLabel airportSuccessLabel = new JLabel();
    
    public ViewCreateAirport() {
        setLayout(new FlowLayout());
        add(airportNameLabel);
        add(airportNameTxt);
        add(airportLocationLabel);
        add(airportLocationTxt);
        add(airportTaxLabel);
        add(airportTaxTxt);
        add(airportButton);
        add(airportSuccessLabel);
        airportButton.addActionListener(new AdapterUCCToAL(UCCreateAirport));
        validate();
    }

    public void loadData() {
        model.setAPName(airportNameTxt.getText());
        model.setAPLocation(airportLocationTxt.getText());
        model.setAPTax(airportTaxTxt.getText());
    }

    public void loadTo(CreateAirport model) {
        this.model = model;
    }

    public void refresh() {
        airportNameTxt.setText("");
        airportLocationTxt.setText("");
        airportTaxTxt.setText("");
        airportSuccessLabel.setText(TEXT2);
        validate();
    }

    public void updateFailure() {
        ViewMain.getInstance().updateMsg(TEXT);
    }
}
